package com.dsc.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author: Du Shun Chang
 * @title: Rediration
 * @date: 2022/2/6 22:53
 * @description: 重定向
 * @version：1.0
 */
public class Rediration extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
       /* 重定向的核心为：
       resp.setHeader("Location", "/JavaWeb_demo_4_ForwardRedirection_war/success.jsp");
       resp.setStatus(302);*/
        /*转发要写请求地址的全路径*/
        resp.sendRedirect("/JavaWeb_demo_4_ForwardRedirection_war/success.jsp");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    }
}
